import * as TYPES from '../../actions/actionTypes'
const initialState = {
    loading: true,
    keyword: '',
    dataList: null,
    pageNum: 0,
    hasMore: true,
    pageSize: 10,
    PurchaseDetail: null,
    purchasePlist: [],
}

export default function Purchase(state = initialState, action) {
    switch (action.type) {
        case TYPES.PURCHASE_DATA_ING:
            return {
                ...state,
                loading: true
            };
        case TYPES.PURCHASE_DATA_SUCCESS:
            return {
                ...state,
                loading: false,
                dataList: action.dataList,
                pageNum: action.pageNum,
                hasMore: action.hasMore,
                keyword: action.keyword
            };
        case TYPES.PURCHASE_DATA_FAIL:
            return {
                ...state,
                loading: false,
                dataList: null,
            };
        case TYPES.PURCHASE_DATA_UPDATE:
            return {
                ...state,
                dataList: action.data
            };
        case TYPES.PURCHASE_DATA_DETAIL_ING:
            return {
                ...state,
                loading: true
            };
        case TYPES.PURCHASE_DETAIL_DATA_INIT:
            return {
                ...state,
                PurchaseDetail: action.data
            }
        case TYPES.PURCHASE_DATA_DETAIL_SUCCESS:
            return {
                ...state,
                loading: false,
                purchasePlist: action.data
            };
        case TYPES.PURCHASE_DATA_DETAIL_FAIL:
            return {
                ...state,
                purchasePlist: null
            }
        default:
            return state
    }
}